<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%exhibitor}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $logo
 * @property string $telphone
 * @property string $url
 * @property string $postcode
 * @property string $province
 * @property string $city
 * @property integer $province_id
 * @property integer $city_id
 * @property string $address
 * @property string $intro
 * @property string $contact_user
 * @property string $contact_mobile
 * @property string $contact_job
 * @property string $product
 * @property integer $industry_id
 * @property string $industry
 * @property string $start_time
 * @property string $registered_capital
 * @property string $license
 * @property integer $order
 * @property integer $status
 * @property integer $version
 * @property string $created_by
 * @property integer $created_at
 * @property string $created_from
 * @property string $created_ip
 * @property string $updated_by
 * @property integer $updated_at
 * @property string $updated_from
 * @property string $updated_ip
 * @property integer $is_deleted
 *
 * @property ExhibitionExhibitor[] $exhibitionExhibitors
 */
class Exhibitor extends \common\base\BaseActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%exhibitor}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'logo', 'telphone', 'url', 'postcode', 'address', 'intro', 'contact_user', 'contact_mobile', 'contact_job', 'product', 'industry_id', 'start_time', 'registered_capital', 'license'], 'required'],
            [['province_id', 'city_id', 'industry_id', 'order', 'status', 'version', 'created_at', 'updated_at', 'is_deleted'], 'integer'],
            [['name', 'telphone', 'province', 'city', 'contact_user'], 'string', 'max' => 100],
            [['logo', 'intro'], 'string', 'max' => 250],
            [['url', 'address', 'product', 'industry', 'license'], 'string', 'max' => 200],
            [['postcode'], 'string', 'max' => 6],
            [['contact_mobile'], 'string', 'max' => 11],
            [['contact_job', 'created_by', 'created_from', 'created_ip', 'updated_by', 'updated_from', 'updated_ip'], 'string', 'max' => 50],
            [['start_time'], 'string', 'max' => 10],
            [['registered_capital'], 'string', 'max' => 30],
            ['order', 'default', 'value' => 0],
            ['status', 'default', 'value' => self::STATUS_FLAG_NORMAL],
            ['status', 'in', 'range' => [self::STATUS_FLAG_TEMP, self::STATUS_FLAG_NORMAL, self::STATUS_FLAG_STOP]],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'id'),
            'name' => Yii::t('common', 'name'),
            'logo' => Yii::t('common', 'logo'),
            'telphone' => Yii::t('common', 'telphone'),
            'url' => Yii::t('common', 'website'),
            'postcode' => Yii::t('common', 'postcode'),
            'province' => Yii::t('common', 'province'),
            'city' => Yii::t('common', 'city'),
            'province_id' => Yii::t('common', 'province_id'),
            'city_id' => Yii::t('common', 'city_id'),
            'address' => Yii::t('common', 'address'),
            'intro' => Yii::t('common', 'intro'),
            'contact_user' => Yii::t('common', 'contact_user'),
            'contact_mobile' => Yii::t('common', 'contact_mobile'),
            'contact_job' => Yii::t('common', 'contact_job'),
            'product' => Yii::t('common', 'product'),
            'industry_id' => Yii::t('common', 'industry_id'),
            'industry' => Yii::t('common', 'industry'),
            'start_time' => Yii::t('common', 'start_time'),
            'registered_capital' => Yii::t('common', 'registered_capital'),
            'license' => Yii::t('common', 'license'),
            'order' => Yii::t('common', 'order'),
            'status' => Yii::t('common', 'status'),
            'version' => Yii::t('common', 'version'),
            'created_by' => Yii::t('common', 'created_by'),
            'created_at' => Yii::t('common', 'created_at'),
            'created_from' => Yii::t('common', 'created_from'),
            'created_ip' => Yii::t('common', 'created_ip'),
            'updated_by' => Yii::t('common', 'updated_by'),
            'updated_at' => Yii::t('common', 'updated_at'),
            'updated_from' => Yii::t('common', 'updated_from'),
            'updated_ip' => Yii::t('common', 'updated_ip'),
            'is_deleted' => Yii::t('common', 'is_deleted'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getExhibitionExhibitors()
    {
        return $this->hasMany(ExhibitionExhibitor::className(), ['exhibitor_id' => 'id']);
    }
}
